import requests
import subprocess
from functools import partial

subprocess.Popen = partial(subprocess.Popen, encoding='utf-8')

import execjs
def get_data(page):
    url = 'https://interface.bidcenter.com.cn/search/GetSearchProHandler.ashx'
    data = {
        'from': 6137,
        'guid': "da825a3f-0223-4574-ab1f-760eae363bd4",
        'location': 6138,
        'token': "",
        'next_token': "",
        'keywords': "%E6%9C%8D%E5%8A%A1%E5%99%A8",
        'mod': 0,
        'page': page
    }
    headers = {
        'user-agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/128.0.0.0 Safari/537.36 Edg/128.0.0.0'
    }
    response = requests.post(url, data=data, headers=headers)
    with open("main.js", 'r', encoding='utf-8') as f:
        js_code = f.read()
    res = execjs.compile(js_code).call('x', response.text)
    ls = res['other2']['listData']
    for i in ls:
        print(i)


if __name__ == '__main__':
    get_data(2)
